﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Services.Contracts.DTO.Infos;
using Demo.CommonBase.DTO.Infos;
using Demo.Services.Contracts.DTO.Filters;
using Demo.Services.Services.Impl.DomainObjects;
using System.Reflection;
using Demo.CommonBase.Exceptions;
using Demo.CommonBase.Logging;

namespace Demo.Services.Services.Impl.Managers
{
    public class TecnologyManager
    {
        public TecnologyResultInfo GetTecnologies(PaginationInfo pagin, TecnologyFilter filters)
        {
            TecnologyResultInfo result = null;
            TecnologyDomainObject tecnologydo;
            try
            {
                Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                result = tecnologydo.GetTecnologies(pagin, filters);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        
        public TecnologyInfo GetTecnologyById(int id)
        {
            TecnologyInfo result = null;
            TecnologyDomainObject tecnologydo;
            try
            {
                //Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                result = tecnologydo.GetTecnologyById(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        
        public void DeleteTecnology(int id)
        {            
            TecnologyDomainObject tecnologydo;
            try
            {
                //Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                tecnologydo.DeleteTecnology(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }            
        }
        
        public void UpdateTecnology(TecnologyInfo tecnology)
        {            
            TecnologyDomainObject tecnologydo;
            try
            {
                //Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                tecnologydo.UpdateTecnology(tecnology);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }            
        }
        
        public void SaveTecnology(TecnologyInfo tecnology)
        {            
            TecnologyDomainObject tecnologydo;
            try
            {
                Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                tecnologydo.SaveTecnology(tecnology);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }            
        }

        public bool CheckName(int id, string name)
        {
            bool isValid = false;
            TecnologyDomainObject tecnologydo;
            try
            {
                Logger.Info();
                tecnologydo = new TecnologyDomainObject();
                isValid =  tecnologydo.CheckName(id, name);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return isValid;
        }
    }
}
